(include "././obj/class.inc")

(def-class seq obj
	(dec-method :vtable class/seq/vtable)
	(dec-method :get_length class/obj/null :virtual (:r0) (:r0 :r1))
	(dec-method :ref_elem class/obj/null :virtual (:r0 :r1) (:r0 :r1))
	(dec-method :slice class/obj/null :virtual (:r0 :r1 :r2) (:r0 :r1))
	(dec-method :rslice class/obj/null :virtual (:r0 :r1 :r2) (:r0 :r1))
	(dec-method :cat class/obj/null :virtual (:r0 :r1) (:r0))
	(dec-method :find class/obj/null :virtual (:r0 :r1 :r2) (:r0 :r1 :r2))
	(dec-method :rfind class/obj/null :virtual (:r0 :r1 :r2) (:r0 :r1 :r2))
	(dec-method :lisp_length class/seq/lisp_length :static (:r0 :r1) (:r0 :r1))
	(dec-method :lisp_elem class/seq/lisp_eget :static (:r0 :r1) (:r0 :r1))
	(dec-method :lisp_first class/seq/lisp_first :static (:r0 :r1) (:r0 :r1))
	(dec-method :lisp_second class/seq/lisp_second :static (:r0 :r1) (:r0 :r1))
	(dec-method :lisp_third class/seq/lisp_third :static (:r0 :r1) (:r0 :r1))
	(dec-method :lisp_last class/seq/lisp_last :static (:r0 :r1) (:r0 :r1))
	(dec-method :lisp_rest class/seq/lisp_rest :static (:r0 :r1) (:r0 :r1))
	(dec-method :lisp_most class/seq/lisp_most :static (:r0 :r1) (:r0 :r1))
	(dec-method :lisp_find class/seq/lisp_find :static (:r0 :r1) (:r0 :r1))
	(dec-method :lisp_rfind class/seq/lisp_rfind :static (:r0 :r1) (:r0 :r1))
	(dec-method :lisp_slice class/seq/lisp_slice :static (:r0 :r1) (:r0 :r1))
	(dec-method :lisp_partition class/seq/lisp_partition :static (:r0 :r1) (:r0 :r1))
	(dec-method :lisp_cat class/seq/lisp_cat :static (:r0 :r1) (:r0 :r1))
	(dec-method :lisp_each class/seq/lisp_each :static (:r0 :r1) (:r0 :r1))
	(dec-method :lisp_map class/seq/lisp_map :static (:r0 :r1) (:r0 :r1))
	(dec-method :lisp_reduce class/seq/lisp_reduce :static (:r0 :r1) (:r0 :r1))
	(dec-method :lisp_some class/seq/lisp_some :static (:r0 :r1) (:r0 :r1))
	(dec-method :lisp_filter class/seq/lisp_filter :static (:r0 :r1) (:r0 :r1))
	(dec-method :lisp_pling class/seq/lisp_pling :static (:r0 :r1) (:r0 :r1)))

(def-struct seq obj_size)

(defun lisp-elem-index (idx len)
	(vpif `(,idx < 0))
		(vp-add-rr len idx)
		(vp-add-cr 1 idx)
	(endif))
